<?php
set_time_limit(0);

include 'config.php';

$mysqli = new mysqli($dbhost, $dbuser, $dbpwd, $dbName);
if (!$mysqli->set_charset("utf8")) {printf("Error loading character set utf8: %s\n", $mysqliTwo->error);}
 
$quData=json_decode(file_get_contents('./qu.txt'));
 
echo '三年级';
echo "<br />";
foreach ($quData as $k=>$v){
	$sql="SELECT COUNT(id) as COUNT FROM `u3` WHERE qu='".$v."' ";
	$query=$mysqli->query($sql);
	$countInfo=$query->fetch_array();
	$count=$countInfo['COUNT'];
	echo $v, '：',$count;
	echo "<br />";
}

echo "<br /><br />";
echo '四年级';
echo "<br />";
foreach ($quData as $k=>$v){
	$sql="SELECT COUNT(id) as COUNT FROM `u4` WHERE qu='".$v."' ";
	$query=$mysqli->query($sql);
	$countInfo=$query->fetch_array();
	$count=$countInfo['COUNT'];
	echo $v, '：',$count;
	echo "<br />";
}

echo "<br /><br />";
echo '五年级';
echo "<br />";
foreach ($quData as $k=>$v){
	$sql="SELECT COUNT(id) as COUNT FROM `u5` WHERE qu='".$v."' ";
	$query=$mysqli->query($sql);
	$countInfo=$query->fetch_array();
	$count=$countInfo['COUNT'];
	echo $v, '：',$count;
	echo "<br />";
}


echo "<br /><br />";
echo '六年级';
echo "<br />";
foreach ($quData as $k=>$v){
	$sql="SELECT COUNT(id) as COUNT FROM `u6` WHERE qu='".$v."' ";
	$query=$mysqli->query($sql);
	$countInfo=$query->fetch_array();
	$count=$countInfo['COUNT'];
	echo $v, '：',$count;
	echo "<br />";
}
 

